import 'package:flutter/material.dart';
import 'package:jetour_line/aha_jetour_line.dart';
import 'package:jetour_line/aha_manger.dart';
import 'package:jetour_line/pages/home/home_page.dart';
import 'package:jetour_line/pages/line/lineDetail/line_detail_page.dart';
import 'package:jetour_line/utils/page_push_utils.dart';
import 'package:jetour_line/utils/size_fit.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    HYSizeFit.initialize();
    return  const MaterialApp(
        debugShowCheckedModeBanner: false,
        home: HomePage());
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);
  @override
  _HomePageState createState() => _HomePageState();
}

// ios 里
//
// # 和Flutter插件兼容 不能使用NO-IDFA版本
// pod 'AMap3DMap', '9.4.0'
// pod 'AMapLocation'
// pod 'AMapSearch', '9.4.0'
// pod 'AMapFoundation', '1.7.0'

//安卓里
//
//// 地图定位
//implementation 'com.amap.api:location:5.6.2'
//implementation 'com.amap.api:3dmap:8.1.0'
//implementation 'com.amap.api:search:8.1.0'6
//implementation 'com.github.promeg:tinypinyin:2.0.3'
//implementation 'com.github.promeg:tinypinyin-lexicons-android-cncity:2.0.3'

 String token = 'cwOIahUTRNc6NcBV3gIANAAAAAAAAAAF';
// const String token = 'zYMNfb_yR6c7Uqv9tgIARQAAAAAAAAAC';
class _HomePageState extends State<HomePage> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    AhaManger ahaManger = AhaManger();
    ahaManger.shareCallBack = (int type, String title,String subTitle,String logo,String url){
      ///  msg 分享信息
      print('shareCallBack== $subTitle');
    };
    ahaManger.loginCallBack = (Function function){
      ///登录成功（失败）后将所需信息传递
      function(token);
    };


    ///跳转捷途页面
    AhaManger().goJetourCallBack = (String path){
      print('跳转捷途页面$path');
    };

    imageCache.clear();
    imageCache.maximumSize = 10;
    // ///跳转路书页面  type: 1 路书详情  2 共创详情   id:路书、共创id
    // AhaManger().goAhaViewPage(context,1,"101209");//路书详情
    // AhaManger().goAhaViewPage(context,2,"150");//共创详情
  }


  @override
  Widget build(BuildContext context) {
    AhaManger().isUat = false;
    if(AhaManger().isUat){//测试
      token = 'qP0Km4cnQctBJ563JAIASQAAAAAAAAAF';
    }else{//正式
      token = 'lWn5IxqnR0s6iH7PkAIARgAAAAAAAAAF';// ljb
      token = 'EV5aRk8ARwI6NcBV3gIANAAAAAAAAAAF';// dyq
    }
    return Scaffold(
              appBar: AppBar(
          title: const Text("主页"),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                child: const Text("go homePage"),
                onPressed: () {
                  MapUtils.setKey('113978dacd1eba872fec84a8f0828018', '2c1008001a8962da0048ca1a32bcd314');
                  AhaManger().setToken(token);
                  Navigator.push(context,
                    MaterialPageRoute(builder: (context) {
                      return AhaHomePageScreen();
                    }),);
                  // PagePushUtils.push(context,  AhaHomePageScreen());
                },
              ),
              SizedBox(height: 20,),
              GestureDetector(onTap: (){
                AhaManger().goAhaViewPage(context,1,"101209");
              }, child: Text('路书详情')),
              // SizedBox(height: 20,),
              // GestureDetector(onTap: (){
              //   AhaManger().goAhaViewPage(context,2,"150");
              // }, child: Text('共创详情')),
            ],
          ),
        ));
  }
}
